import request from '@/utils/request'

export interface DeptItem {
  id: number
  name: string
  createTime: string
  updateTime: string
}

// 获取部门列表
export function getDeptList() {
  return request.get<DeptItem[]>('/depts')
}

// 删除部门
export function deleteDept(id: number) {
  return request.delete(`/depts/${id}`)
}

// 添加部门
export function addDept(data: { name: string }) {
  return request.post('/depts', data)
}

// 根据ID查询部门
export function getDeptById(id: number) {
  return request.get<DeptItem>(`/depts/${id}`)
}

// 修改部门
export function updateDept(data: { id: number, name: string }) {
  return request.put('/depts', data)
}
